package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhAgentPartsattribute;
import com.ruoyi.zsyh.service.IZsyhAgentPartsattributeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会长商城产品规格Controller
 * 
 * @author yuexl
 * @date 2021-12-16
 */
@Controller
@RequestMapping("/zsyh/agentPartsAttribute")
public class ZsyhAgentPartsattributeController extends BaseController
{
    private String prefix = "zsyh/agentPartsAttribute";

    @Autowired
    private IZsyhAgentPartsattributeService zsyhAgentPartsattributeService;

    @RequiresPermissions("zsyh:agentPartsAttribute:view")
    @GetMapping()
    public String agentPartsAttribute()
    {
        return prefix + "/agentPartsAttribute";
    }

    /**
     * 查询会长商城产品规格列表
     */
    @RequiresPermissions("zsyh:agentPartsAttribute:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhAgentPartsattribute zsyhAgentPartsattribute)
    {
        startPage();
        List<ZsyhAgentPartsattribute> list = zsyhAgentPartsattributeService.selectZsyhAgentPartsattributeList(zsyhAgentPartsattribute);
        return getDataTable(list);
    }

    /**
     * 导出会长商城产品规格列表
     */
    @RequiresPermissions("zsyh:agentPartsAttribute:export")
    @Log(title = "会长商城产品规格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhAgentPartsattribute zsyhAgentPartsattribute)
    {
        List<ZsyhAgentPartsattribute> list = zsyhAgentPartsattributeService.selectZsyhAgentPartsattributeList(zsyhAgentPartsattribute);
        ExcelUtil<ZsyhAgentPartsattribute> util = new ExcelUtil<ZsyhAgentPartsattribute>(ZsyhAgentPartsattribute.class);
        return util.exportExcel(list, "会长商城产品规格数据");
    }

    /**
     * 新增会长商城产品规格
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存会长商城产品规格
     */
    @RequiresPermissions("zsyh:agentPartsAttribute:add")
    @Log(title = "会长商城产品规格", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhAgentPartsattribute zsyhAgentPartsattribute)
    {
        return toAjax(zsyhAgentPartsattributeService.insertZsyhAgentPartsattribute(zsyhAgentPartsattribute));
    }

    /**
     * 修改会长商城产品规格
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhAgentPartsattribute zsyhAgentPartsattribute = zsyhAgentPartsattributeService.selectZsyhAgentPartsattributeById(id);
        mmap.put("zsyhAgentPartsattribute", zsyhAgentPartsattribute);
        return prefix + "/edit";
    }

    /**
     * 修改保存会长商城产品规格
     */
    @RequiresPermissions("zsyh:agentPartsAttribute:edit")
    @Log(title = "会长商城产品规格", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhAgentPartsattribute zsyhAgentPartsattribute)
    {
        return toAjax(zsyhAgentPartsattributeService.updateZsyhAgentPartsattribute(zsyhAgentPartsattribute));
    }

    /**
     * 删除会长商城产品规格
     */
    @RequiresPermissions("zsyh:agentPartsAttribute:remove")
    @Log(title = "会长商城产品规格", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhAgentPartsattributeService.deleteZsyhAgentPartsattributeByIds(ids));
    }

    /**
     * 规格图片
     */
    @GetMapping("/avatarAttribute")
    public String avatarAttribute(String attributeLogo,ModelMap mmap)
    {
        mmap.put("avatar",attributeLogo);
        return prefix + "/avatarAttribute";
    }

}
